<template>
  <div class="container" id="customers-list">
    <!-- 面包屑导航 -->
    <div class="breadcrumb">
      <el-breadcrumb separator="">
        <el-breadcrumb-item
        >
          <div class="div1">客户管理</div>
        </el-breadcrumb-item
        >
        <el-breadcrumb-item
        >
          <div class="div2">资源列表</div>
        </el-breadcrumb-item
        >
      </el-breadcrumb>
    </div>
    <div class="content">
      <h2>资源列表</h2>
      <h3>数据筛选</h3>
      <el-form :inline="true" id="search" class="search-form" size="small">
        <el-form-item label="订单编号">
          <el-input
              v-model="search.orderNo"
              placeholder="请输入订单编号"
              clearable
              @keyup.native.enter="fetchData('search')"
          ></el-input>
        </el-form-item>
        <el-form-item label="客户信息">
          <el-input
              v-model="search.keywords"
              placeholder="请输入客户姓名或手机号"
              clearable
              @keyup.native.enter="fetchData('search')"
          ></el-input>
        </el-form-item>
        <el-form-item label="商品名称">
          <el-input
              v-model="search.goodsName"
              placeholder="请输入商品名称"
              clearable
              @keyup.native.enter="fetchData('search')"
          ></el-input>
        </el-form-item>
        <el-form-item label="渠道">
          <el-select
              v-model="search.userDitch"
              placeholder="请选择渠道"
              clearable
              filterable

          >
            <el-option
                v-for="item in userDitchList"
                :key="item.id"
                :label="item.name"
                :value="item.id"
                clearable
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="来源">
          <el-select
              v-model="search.platformId"
              placeholder="请选择来源平台"
              filterable
              clearable
          >
            <el-option
                v-for="item in platformList"
                :key="item.id"
                :label="item.name"
                :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="部门">
          <el-cascader
              v-model="search.orgCode"
              :options="orgCodeList"
              :props="{
              checkStrictly: true,
              label: 'orgName',
              value: 'orgCode',
              children: 'children',
            }"
              clearable
              filterable
          ></el-cascader>
        </el-form-item>

        <el-form-item label="创建时间">
          <el-date-picker
              v-model="createDate"
              type="daterange"
              unlink-panels
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              format="yyyy-MM-dd HH:mm:ss"
              value-format="yyyy-MM-dd HH:mm:ss"
              :default-time="['00:00:00', '23:59:59']"
              @change="onChangeCreate"
          >
          </el-date-picker>
        </el-form-item>
        <!-- <el-form-item label="分配时间">
          <el-date-picker
              v-model="date"
              type="daterange"
              unlink-panels
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
              @change="onChangeDate"
          >
          </el-date-picker>
        </el-form-item> -->
        <el-form-item label="分配客服">
          <el-select
              v-model="search.customerServiceUserId"
              placeholder="请选择跟进客服"
              clearable
              filterable
          >
            <el-option
                v-for="item in salesAuthorityList"
                :key="item.id"
                :label="item.reallyName"
                :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="类型">
          <el-select
              v-model="search.payType"
              placeholder="请选择类型"
              clearable
              filterable
          >
            <el-option
                v-for="item in dictionaries.customer_channel_pay_type"
                :key="item.dictId"
                :label="item.dictName"
                :value="item.dictId"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="类目">
          <el-cascader
              clearable
              v-model="search.categoryId"
              :options="categoryOptions"
              :props="{
              label: 'categoryName',
              value: 'id',
              checkStrictly: true,
            }"
              filterable
              @change="handleChangeSearch"
          ></el-cascader>
        </el-form-item>
        <el-form-item label="分配人">
          <el-select
              v-model="search.assignUserId"
              placeholder="请选择分配人"
              clearable
              filterable
          >
            <el-option
                v-for="item in assignorList"
                :key="item.id"
                :label="item.reallyName"
                :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
<!--        <el-form-item label="标签">
          <el-cascader
              @change="handlerTagDataList"
              v-model="search.tags"
              :options="tagDataList"
              :props="{
              multiple: true,
              label: 'name',
              value: 'id',
              children: 'tierList',
            }"

          ></el-cascader>
        </el-form-item>
        <el-form-item label="分群">
          <el-cascader
              @change="handlerCrowdDataList"
              v-model="search.crowds"
              :options="crowdDataList"
              :props="{
              multiple: true,
              label: 'name',
              value: 'id',
              children: 'tierList',
            }"
          ></el-cascader>
        </el-form-item>-->
         <el-form-item label="批次">
          <el-input
              v-model="search.batchNumber"
              placeholder="请输入批次"
              clearable
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary"
          @click="fetchData('search')"
          >查询
          </el-button>
          <el-button
              type="primary"
              plain
              @click="fetchData('reset')"
          >重置
          </el-button
          >
        </el-form-item
        >
      </el-form>
    </div>
    <div class="content">
      <h3>资源分配列表</h3>
      <div class="btn-list">
        <div>
          <el-button
              :disabled="loading"
              plain
              :type="
              assignStatusCurrent === assignStatus.all ? 'primary' : 'info'
            "
              @click="onChangeAssignStatus(assignStatus.all)"
          >全部
          </el-button
          >
          <el-button
              :disabled="loading"
              plain
              :type="
              assignStatusCurrent === assignStatus.distributable
                ? 'primary'
                : 'info'
            "
              @click="onChangeAssignStatus(assignStatus.distributable)"
          >可分配({{ distributionCount.wechatUnassignedNum }})
          </el-button
          >
          <el-button
              :disabled="loading"
              size="mini"
              plain
              :type="
              assignStatusCurrent === assignStatus.fail ? 'primary' : 'info'
            "
              @click="onChangeAssignStatus(assignStatus.fail)"
          >分配失败({{ distributionCount.wechatAssignedErrorNum }})
          </el-button
          >
          <el-button
              :disabled="loading"
              size="mini"
              plain
              :type="
              assignStatusCurrent === assignStatus.success ? 'primary' : 'info'
            "
              @click="onChangeAssignStatus(assignStatus.success)"
          >分配成功
          </el-button
          >
        </div>
        <div>
          <el-button
              size="mini"
              @click="onDetail('e', 2)"
              plain
              v-if="parArray.indexOf('allocation') != -1"
          >批量分配
          </el-button
          >
           <el-button
              size="mini"
              @click="batchDelete()"
              type="danger"
              plain
              v-if="assignStatusCurrent==3"
          >批量删除
          </el-button
          >
          <el-button
              size="mini"
              @click="importClient"
              type="primary"
              v-if="parArray.indexOf('ImportClient') != -1"
          >导入客户
          </el-button
          >
          <el-button
              size="mini"
              @click="resourceFeedback"
              type="success"
          >资源反馈
          </el-button
          >
          <el-button
          v-if="assignStatusCurrent==2"
              size="mini"
              @click="automationAllocation"
              type="warning"
          >自动分配
          </el-button
          >
          <!-- <el-button size="mini" type="warning" >自动分配设置</el-button> -->
        </div>
      </div>
      <lb-table
      v-horizontal-scroll='"always"'
          v-loading="loading"
          :column="column"
          :data="list"
          pagination
          :total="page.totalNum"
          layout="total, sizes, prev, pager, next, jumper"
          :page-sizes="[5, 10, 20, 30, 50]"
          :current-page.sync="page.currentPage"
          :page-size="page.pageSize"
          @size-change="handleSizeChange"
          @p-current-change="handleCurrentChange"
          @selection-change="handleSelectionChange"
      >
      </lb-table>
    </div>
    <!-- 自定分配弹框设置开始 -->
    <el-dialog
        :visible.sync="allocation"
        :append-to-body="true"
        title="自动分配"
        @close="handleAllocationDialogClose"
        :close-on-click-modal='false'
    >
      <template>
        <div class="allocationForm">
          <el-form :inline="true" :model="allocationForm" :rules="allocationRuleForm" ref="allocationForm" class="demo-ruleForm">
            <el-form-item label="分配计算方式" prop="calculateWay" >
             <el-select
                  size="mini"
                v-model="allocationForm.calculateWay"
                placeholder="请选择更新方式"
                filterable
                clearable
                @change="handlerSelectedNum"
            >
              <el-option
                  v-for="item in dictionaries.auto_assign_type"
                  :key="item.dictId"
                  :label="item.dictName"
                  :value="item.dictId"
              >
              </el-option>
            </el-select>
            </el-form-item>
             <el-form-item label="类目" prop="clientCategory">
              <el-cascader
                  placeholder="请选择二级类目"
                  size="mini"
                  clearable
                  v-model="allocationForm.clientCategory"
                  :options="categoryOptions"
                  ref="cascade"
                  :props="{
                    label: 'categoryName',
                    value: 'id',
                    checkStrictly: true,
                  }"
                  filterable
                  @change="selectClientCategory"
              ></el-cascader>
            </el-form-item>
             <el-form-item label="已选数量" v-if="allocationForm.calculateWay==4">
                 <el-input
                    style="width:60%"
                    size="mini"
                    v-model="allocationForm.selectedNum"
                    placeholder="请输入已选数量"
                    clearable
                     @input="v=> allocationForm.selectedNum = v.replace(/[^\d]/g,'')"
                    @change="handlerInputNumber"
                ></el-input>
              <span class="peopleNum">人数:{{numberPeople}}</span>
            </el-form-item>
          </el-form>
        </div>

        <div class="allocation_box">
          <div class="allocation_left">
            <div class="allocation_left_title">选择部门</div>
            <div class="treeAllocation">
              <el-input
                  placeholder="输入关键字进行搜索"
                  v-model="filterText"
                  prefix-icon="el-icon-search"
              ></el-input>
              <el-tree
                  class="el-menu-vertical-demo"
                  ref="allocationTree"
                  :data="orgCodeList"
                   node-key="id"
                  :default-expand-all="true"
                  :props="defaultPropsNew"
                  :highlight-current="true"
                  @node-click="handleNodeClickTwo"
                  :filter-node-method="filterNode"
              >

               <span class="custom-tree-node" slot-scope="{ node, data }">
                <span>{{ node.label }}</span>
                <span>
                  <el-badge v-if="node.level != 1&&data.selectedList.length!=0" :value="data.selectedList.length" type="primary"></el-badge>
                </span>
              </span>
              </el-tree>
            </div>
          </div>
          <div class="allocation_right">
            <div class="allocation_right_titleBox">
              <div class="allocation_right_title">
                已选员工：{{selectedStaff.length}}人
              </div>
              <div class="allocation_right_title_right">
                <span v-if="numberEstimate&&numberEstimate!=0">预估已选人均分配数量：{{numberEstimate=='Infinity'?'0':numberEstimate}}</span>
                <span v-else>预估已选人均分配数量：{{estimatesNum=='Infinity'?'0':estimatesNum}}</span>
                <span>
                  <el-button type="primary" class="allocation_right_title_btn" @click="handlerEstimate">预估</el-button>
                </span>
              </div>
            </div>
            <div class="table2">
              <el-table
                  v-loading="allocationLoading"
                 :header-cell-style="{ background: '#f8f8f8' }"
                  ref="allocation"
                  :data="staffTableList.list"
                  style="width: 100%"
                  row-key="id"
                  @select-all="handleAutomaticAllocationAll"
                  @select="handleAutomaticAllocationSelect"
              >
                <el-table-column
                  type="selection"
                  :reserve-selection="true"
                  width="50"
                  align="center"
                  v-model="automaticAllocation"
                ></el-table-column>

                <el-table-column label="员工">
                  <template slot-scope="props">
                    <p>{{ props.row.reallyName }}</p>
                  </template>
                </el-table-column>
                <el-table-column label="已分配资源数" prop="allocationNum" >
                  <template slot="header">
                      <span> 预估分配{{valueName}} </span>
                  </template>
                  </el-table-column>
                <el-table-column label="预估分配数量" >

                   <template slot="header">
                      <span> 设置分配{{valueName}} </span>
                  </template>
                  <template slot-scope="props">
                    <!-- <span>{{ props.row.orgName }}</span> -->
                    <el-input  v-model="props.row.assignNum"></el-input>
                  </template>
                </el-table-column>
                <el-table-column label="上次分配时间" prop="assignTime">
                  <template slot-scope="props">
                    <!-- <span>{{ props.row.orgName }}</span> -->
                   {{props.row.assignTime?props.row.assignTime:'-'}}
                  </template>
                </el-table-column>
              </el-table>
            </div>
            <!-- 弹突层分页start -->
            <div class="allocation_pagination" v-if="staffTableList.totalNum > 0">
              <div class="block">
                <el-pagination
                    @size-change="handleSizeEmplayNew"
                    @current-change="handleCurrentEmplayNew"
                    :current-page.sync="stafpage"
                    :page-size="stafPageSize"
                    layout="total,sizes,prev, pager, next"
                    prev-text="上一页"
                    next-text="下一页"
                    :total="staffTableList.totalNum"
                >
                </el-pagination>
              </div>
            </div>
            <div>
              <div class="result_title">预估分配结果</div>
              <div class="result" v-if="showDataList">
                <span v-for="(item,index) in selectedStaff" :key="index" class="result_item">
                  <span>{{index + 1}}.</span><span>{{item.reallyName}}</span>
                  <span style="margin-left:15px">{{item.showAssignNum}}{{unit}}</span>
                </span>
              </div>
              <div class="result" v-if="!showDataList">
                <span v-for="(item,index) in selectedStaff" :key="index" class="result_item">
                  <span>{{index + 1}}.</span><span>{{item.reallyName}}</span>
                  <span  style="margin-left:15px">{{item.allocationNum}}{{unit}}</span>
                </span>
              </div>
            </div>
          </div>
        </div>

        <div slot="footer" class="dialog-footer">
          <el-button size="mini" @click="handleAllocationDialogClose"
          >取 消
          </el-button
          >
          <el-button
              size="mini"
              type="primary"
              @click="allocationSubmit('allocationForm');
            "
          >分 配
          </el-button
          >
        </div>
        <!-- 分页end -->
      </template>
    </el-dialog>
    <!-- 分配结果弹框 -->
     <el-dialog
        :visible.sync="resultDialog"
        :append-to-body="true"
        title="分配结果"
        @close="handleResultDialog"
        width="630px"
    >
        <el-table v-loading="loading" :data="showData">
          <el-table-column property="sysUserName" label="姓名" width="200"></el-table-column>
          <el-table-column property="address" label="成功/失败">
            <template slot-scope="props">
             <div class="resultDialogStyle"><span>{{props.row.successNum}}</span><span>/</span><span :style="props.row.failedNum>=1?'color:red':''">{{props.row.failedNum}}</span></div>
            </template>
          </el-table-column>
        </el-table>
         <div class="block">
                <el-pagination
                    @size-change="handleSizeAllocation"
                    @current-change="handleCurrentAllocation"
                    :current-page.sync="resultDialogPageNo"
                    :page-size="resultDialogPageSize"
                     layout="total, prev, pager, next, jumper"
                    :total="resultDialogTotal"
                >
                </el-pagination>
              </div>
    </el-dialog>
    <!-- 分配结果弹框结束 -->
    <!-- 自动分配设置弹框结束 -->
    <el-dialog
        :visible.sync="leadingInLive"
        :append-to-body="true"
        title="导入客户"
        @close="handleDialogClose"
        width="400px"
    >
      <div class="popIn">
        <el-upload
            ref="tops"
            class="upload-demo"
            accept=".doc,.docx,.xls,.xlsx,.csv"
            drag
            action="#"
            :multiple="false"
            :http-request="orderImportLive"
            :limit="1"
        >
          <i class="el-icon-upload"></i>
          <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        </el-upload>
      </div>
      <div
          slot="footer"
          class="dialog-footer"
          style="display: flex; justify-content: space-between"
      >
        <div>
          <el-button
              icon="el-icon-download"
              size="mini"
              type="text"
              @click="
              DownloadTemplate();
              leadingInLive = false;
            "
          >导入模板下载
          </el-button
          >
        </div>
        <div>
          <el-button
              size="mini"
              @click="
              leadingInLive = false;
              $refs['tops'].clearFiles();
            "
          >取 消
          </el-button
          >
          <el-button
              size="mini"
              type="primary"
              @click="submission
              templateMode();
              guideId = '';

            "
          >确 定
          </el-button
          >
        </div>
      </div>
    </el-dialog>
    <!-- 分配用户列表 -->
    <el-dialog
        id="show-el-dialog"
        :visible.sync="dialog.visible"
        :append-to-body="true"
        :title="dialog.title"
    >
      <template>
        <div style="width:250px">
          <el-form :rules="rulesClientCategory" :model="ruleForm" ref="ruleForm" class="demo-ruleForm">
            <el-form-item label="类目" prop="clientCategory">
              <el-cascader
                  size="mini"
                  clearable
                  v-model="ruleForm.clientCategory"
                  :options="categoryOptions"
                  :props="{
                    label: 'categoryName',
                    value: 'id',
                    checkStrictly: true,
                  }"
                  filterable
                  @change="handleClientCategory"
              ></el-cascader>
            </el-form-item>
          </el-form>
        </div>
        <div style="display: inline-block; margin: 0px 20px">
          员工姓名
          <el-input
              v-model="formTc.username"
              placeholder="请输入员工姓名"
              size="small"
              style="width: 150px"
          ></el-input>
        </div>
        <el-button size="mini" @click="treeAxios(1)" type="primary">
          搜索
        </el-button>
        <el-button size="mini" @click="treeAxios(2)" type="warning">
          重置
        </el-button>
        <div class="tree">
          <el-input
              style="margin: 0 0px 20px"
              placeholder="输入关键字进行搜索"
              v-model="filterText"
          ></el-input>
          <el-tree
              class="el-menu-vertical-demo"
              ref="tree"
              :data="tree"
              :props="defaultProps"
              :highlight-current="true"
              @node-click="handleNodeClick"
              :default-expand-all="true"
              :filter-node-method="filterNode"
          ></el-tree>
        </div>
        <div class="table1">
          <el-table
              ref="multipleTable"
              :data="tablePerson.list"
              style="width: 100%"
              :row-key="getRowKey"
          >
            <!-- <el-table-column
              type="selection"
              :reserve-selection="true"
              width="50"
              align="center"
              v-model="multipleSelection"
            ></el-table-column> -->
            <el-table-column width="50">
              <template slot-scope="scope">
                <el-radio
                    :label="scope.$index"
                    v-model="multipleSelection"
                    @change.native="getCurrentRow(scope.row)"
                    style="color: #fff"
                >
                  <span>&nbsp;</span>
                </el-radio>
              </template>
            </el-table-column>

            <el-table-column label="姓名">
              <template slot-scope="props">
                <p>{{ props.row.reallyName }}</p>
              </template>
            </el-table-column>
            <el-table-column
                label="联系电话"
                prop="phoneNumber"
            ></el-table-column>
            <el-table-column label="所在部门">
              <template slot-scope="props">
                <span>{{ props.row.orgName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="职位" prop="positionName"></el-table-column>
            <el-table-column
                label="员工状态"
                prop="statusName"
            ></el-table-column>
          </el-table>
        </div>
        <!-- 弹突层分页start -->
        <div class="page2" v-if="tablePerson.totalNum > 0">
          <div class="block">
            <el-pagination
                @size-change="handleSizeEmplay"
                @current-change="handleCurrentEmplay"
                :current-page.sync="stafpage"
                :page-size="stafPageSize"
                layout="total,sizes,prev, pager, next"
                prev-text="上一页"
                next-text="下一页"
                :total="tablePerson.totalNum"
            >
            </el-pagination>
          </div>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button size="mini" @click="dialog.visible = false"
          >取 消
          </el-button
          >
          <el-button
              size="mini"
              type="primary"
              @click="submission('ruleForm');
            "
          >确 定
          </el-button
          >
        </div>
        <!-- 分页end -->
      </template>
      <template v-if="dialog.type == 'add'">
        <add-customers
            ref="addCustomers"
            v-on:closeDialog="closeDialog"
        ></add-customers>
      </template>
    </el-dialog>
    <!-- 导入客户弹框详情 -->
    <el-dialog
        title="导入客户"
        append-to-body
        :visible.sync="importDialogVisible"
        width="90%"
        class="dialog"
    >
      <div class="statistics">
        <div class="statistics_item" style="color: #e6a23c">
          导入失败 : {{ statistics.exportFail }}
        </div>
        <div class="statistics_item" style="color: #67c23a">
          导入成功 : {{ statistics.exportSuccess }}
        </div>
        <div class="statistics_item" style="color: #909399">
          未分配 : {{ statistics.assignoreFail }}
        </div>
        <div class="statistics_item" style="color: #67c23a">
          分配成功 : {{ statistics.assignoreSuccess }}
        </div>
      </div>
      <el-table
          border
          :header-cell-style="{ background: '#f8f8f8' }"
          :data="importDataList.list"
          style="width: 100%"
      >
        <el-table-column type="index" label="批次" width="60"></el-table-column>
        <el-table-column prop="resourceId" label="资源ID" width="120">
        </el-table-column>
        <el-table-column prop="orderNo" label="订单编号" width="150">
        </el-table-column>
        <el-table-column show-overflow-tooltip label="客户信息">
          <template slot-scope="scope">
            <p>{{ scope.row.customerName }}</p>
            <p>{{ scope.row.customerPhone }}</p>
          </template>
        </el-table-column>

        <el-table-column show-overflow-tooltip label="类目">
          <template slot-scope="scope">
            <p>{{ scope.row.categoryName }}</p>
          </template>
        </el-table-column>

        <el-table-column prop="prodName" label="选购商品" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="channelName " label="渠道" width="60">
          <template slot-scope="scope">
            <span>{{ scope.row.channelName }} </span>
          </template>
        </el-table-column>
        <el-table-column prop="platformName" label="来源" width="80">
        </el-table-column>
        <el-table-column prop="payType" label="类型" width="85">
        </el-table-column>
        <el-table-column prop="assignorTeamName" label="公司部门" width="100">
        </el-table-column>
        <el-table-column prop="assignorName" label="跟进客服" width="90">
        </el-table-column>
        <el-table-column prop="address" label="分配人" width="100">
          <template>
            <span>{{ useName.reallyName }} </span>
          </template>
        </el-table-column>
        <el-table-column prop="address" label="状态" width="80">
          <template slot-scope="scope">
            <span
                :style="
                scope.row.errorType == null
                  ? 'color:#909399'
                  : '' || scope.row.errorType == 0
                  ? 'color:#67C23A'
                  : '' || scope.row.errorType > 0
                  ? 'color:#F56C6C'
                  : ''
              "
            >{{
                scope.row.errorType == null
                    ? '导入失败'
                    : '' || scope.row.errorType == 0
                        ? '分配成功'
                        : '' || scope.row.errorType > 0
                            ? '分配失败'
                            : '' || scope.row.errorType == -1
                                ? '未分配'
                                : ''
              }}
            </span>
          </template>
        </el-table-column>
        <el-table-column   prop="errorDescription " label="失败原因1" width="240">
          <template slot-scope="scope">
            <span>{{ scope.row.errorDescription }} </span>
          </template>
        </el-table-column>
        <el-table-column prop="createTime" label="创建时间"></el-table-column>
        <el-table-column prop="assignTime" label="分配时间"></el-table-column>
      </el-table>
      <div style="display: flex; justify-content: right; background: #f8f8f8">
        <el-pagination
            @size-change="handleSizeImport"
            @current-change="handleCurrentImport"
            :current-page.sync="importPage"
            :page-size="importPageSize"
            layout="total,sizes,prev, pager, next"
            prev-text="上一页"
            next-text="下一页"
            :total="importDataList.totalNum"
        >
        </el-pagination>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button
            @click="
            importDialogVisible = false;
            fetchData();
          "
        >取 消</el-button
        >
        <el-button
            type="primary"
            @click="
            importDialogVisible = false;
            fetchData();
          "
        >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { isRegExp } from 'xe-utils/methods'
import LbTable from '../../components/lb-table/lb-table'
import common from '../LabelGroup/mixins/common'

export default {
  mixins: [common],
  components: { LbTable },
  data () {
    return {
      lastTime: 0, // f防抖使用
      allocationLoading: false, // 分配加载
      selectDataList: [], // 自动分配勾选的数据
      showDataList: false,
      clientCategoryData: '', // 自动分配设置类目选择
      numberEstimate: '0', // 手动平均分配值
      estimateNumberTwo: '0', // 手动平均分配值
      unit: '', // 单位
      showEstimateNumber: '', // 输入框输入的值再平均分配后的数
      residueNumber: 0, // 没有输入的值
      selectData: [],
      noSelectData: [],
      showData: [],
      resultDialogPageNo: 1, //
      resultDialogPageSize: 10,
      resultDialogTotal: 0,
      currentPagingData: [], // 当前分页数据

      resultDataList: [], // 分配结果弹框
      resultDialog: false, // 分配结果弹框
      valueName: '', //
      totalValue: '', //
      estimatesNum: '0', // 预估人数显示数量
      estimateNumber: '0', // 点击预估按钮后得出的数量
      predictNumber: '0',
      numberPeople: '0', // 可分配资源数量
      groupIdList: [], // 分群idList
      groupTierIdList: [], // 分层idList
      tagIdList: [], // 标签idList
      tagTierIdList: [], // 分层idList
      crowdDataList: [], // 人群下拉数据
      tagDataList: [], // 标签下拉数据
      selectedLength: [],
      selectNum: 0, // 部门已选数量
      selectedStaff: [], // 已选员工数量
      automaticAllocation: '', // 自动分配多选
      allocation: false, // 自动分配
      loading: false,
      sessionDictionaries: {}, // 缓存字典
      ruleForm: {
        clientCategory: '' // 客户类目
      },
      allocationForm: { // 自定义分配设置输入框
        calculateWay: '4', // 分配计算方式
        selectedNum: '', // 已选数量
        clientCategory: '' // l类目
      },
      serviceId: '', // 客服id
      tablePerson: [],
      staffTableList: [],
      defaultProps: {
        children: 'children',
        label: 'orgName'
      },
      defaultPropsNew: {
        children: 'children',
        label: 'orgName',
        sort: 'sort'
      },
      selectionCustomer: '', // 列表id
      filterText: '', // 员工搜索
      orgCode: '',
      tree: [],
      stafpage: 1,
      stafPageSize: 10,
      importPage: 1,
      importPageSize: 10,
      allocationPage: 1, // 分配结果弹框分页
      allocationPageSize: 10, // 分配结果弹框分页
      formTc: { username: '' },
      dialog: { visible: false, title: '分配', type: '', obj: {}},
      tableMultipleSelection: [], // 表格多选
      multipleSelection: [], // 弹框表格单选
      leadingInLive: false,
      date: '',
      createDate: '',
      search: {
        orderNo: '', // 否 	string 	订单编号
        keywords: '', // 否 	string 	客户信息
        goodsName: '', // 否 	string 	选购商品
        userDitch: '', // 否 	string 	渠道（数据来源【入线渠道设定】）
        platformId: '', // 是 	int 	来源平台id
        orgCode: [], // 否 	string 	部门编号
        assignTimeStart: '', // 否 	String 	分配时间开始
        assignTimeEnd: '', 	// 否 	String 	分配时间结束
        payType: '', // 否 	string 	类型（字典分组：customer_channel_pay_type）
        assignUserId: '', // 否 	string 	分配人id
        categoryId: '', // 类目
        customerServiceUserId: '',
        crowds: '', // 人群
        tags: '', // 标签，
        batchNumber: '' // 批次

      },
      categoryOptions: [],
      rulesClientCategory: {
        clientCategory: [
          { required: true, message: '请选择类目', trigger: 'change' }
        ]
      },
      allocationRuleForm: { // 自定义分配方式校验
        calculateWay: [
          { required: true, message: '请选择分配计算方式', trigger: 'change' }
        ],
        clientCategory: [
          { required: true, message: '请选择类目', trigger: 'change' }
        ]
      },
      list: [], // 表单数据列表
      column: this.columnCommon,
      // 公共  column
      columnCommon: [
        { type: 'selection', fixed: 'left' },
        {
          label: '批次', prop: 'batchNumber', width: '150',
          render: (h, scope) => {
            return (
              <div>
                <p>{scope.row.batchNumber ? scope.row.batchNumber : '-'}</p>
              </div>
            )
          }
        },
        {
          label: '资源ID', prop: 'resourceId', width: '120',
          render: (h, scope) => {
            return (
              <div>
                <p>{scope.row.resourceId ? scope.row.resourceId : '-'}</p>
              </div>
            )
          }
        },
        {
          label: '订单编号', prop: 'orderNo', width: '150',
          render: (h, scope) => {
            return (
              <div>
                <p>{scope.row.orderNo ? scope.row.orderNo : '-'}</p>
              </div>
            )
          }
        },
        {
          label: '客户信息',
          width: '120',
          render: (h, scope) => {
            return (
              <div>
                <p>{scope.row.customerName ? scope.row.customerName : '-'}</p>
                <el-tooltip
                  class='item'
                  effect='dark'
                  content='单击复制'
                  placement='top'
                >
                  <p style='cursor:pointer' onClick={() => { this.copyInfoPhone(scope.row) }}>{scope.row.customerPhone ? scope.row.customerPhone : '-'}</p>
                </el-tooltip>
              </div>
            )
          }
        },
        {
          label: '类目', prop: 'categoryName', width: '100',
          render: (h, scope) => {
            return (
              <div>
                <p>{scope.row.categoryName ? scope.row.categoryName : '-'}</p>
              </div>
            )
          }
        },
        {
          label: '选购商品', prop: 'prodName', width: '200',
          render: (h, scope) => {
            return (
              <div>
                <p>{scope.row.prodName ? scope.row.prodName : '-'}</p>
              </div>
            )
          }
        },
        {
          label: '渠道', prop: 'channelName',
          render: (h, scope) => {
            return (
              <div>
                <p>{scope.row.channelName ? scope.row.channelName : '-'}</p>
              </div>
            )
          }
        },
        {
          label: '来源', prop: 'sourceFrom',
          render: (h, scope) => {
            return (
              <div>
                <p>{scope.row.sourceFrom ? scope.row.sourceFrom : '-'}</p>
              </div>
            )
          }
        },
        {
          label: '类型', prop: 'payTypeLabel',
          render: (h, scope) => {
            return (
              <div>
                <p>{scope.row.payTypeLabel ? scope.row.payTypeLabel : '-'}</p>
              </div>
            )
          }
        }
      ],
      // 操作
      columnOperation: [
        {
          label: '操作',
          width: '180',
          fixed: 'right',
          render: (h, scope) => {
            if (this.parArray.indexOf('allocation') != -1) {
              // 分配失败 才显示 删除按钮
              if (this.assignStatusCurrent == 3) {
                return (
                  <div style='display:flex;justify-content: space-evenly'>
                    <el-link size='mini' type='primary' onClick={() => {
                      this.onDetail(scope.row, 1)
                    }}>分配
                    </el-link>
                    <el-link class={scope.row.customerId == null || scope.row.customerId == '' ? 'hide-content' : ''} size='mini' type='primary' onClick={() => {
                      this.toInformation(scope.row)
                    }}>查看
                    </el-link>
                    <el-link size='mini' type='primary' onClick={() => {
                      this.copyInfo(scope.row)
                    }}>复制
                    </el-link>
                    <el-link size='mini' type='primary' onClick={() => {
                      this.resourceDelete(scope.row)
                    }}>删除
                    </el-link>
                  </div>
                )
              } else {
                return (
                  <div style='display:flex;justify-content: space-evenly'>
                    <el-link size='mini' type='primary' onClick={() => {
                      this.onDetail(scope.row, 1)
                    }}>分配
                    </el-link>
                    <el-link class={scope.row.customerId == null || scope.row.customerId == '' ? 'hide-content' : ''} size='mini' type='primary' onClick={() => {
                      this.toInformation(scope.row)
                    }}>查看
                    </el-link>
                    <el-link size='mini' type='primary' onClick={() => {
                      this.copyInfo(scope.row)
                    }}>复制
                    </el-link>
                  </div>
                )
              }
            } else {
              return (
                <div style='display:flex;justify-content: space-evenly'>
                  <el-link class={scope.row.customerId == null || scope.row.customerId == '' ? 'hide-content' : ''} size='mini' type='primary' onClick={() => {
                    this.toInformation(scope.row)
                  }}>查看
                  </el-link>
                  <el-link size='mini' type='primary' onClick={() => {
                    this.copyInfo(scope.row)
                  }}>复制
                  </el-link>
                </div>
              )
            }
          }
        }
      ],
      columnCompanyPeople: [
        { label: '公司部门', prop: 'orgName', minWidth: '180' },
        { label: '跟进客服', width: '120',
          render: (h, scope) => {
            return (
              <p style={scope.row.customerServiceStatus == 'S' ? 'color:red' : '' }>{scope.row.customerServiceName ? scope.row.customerServiceName : '-'}</p>
            )
          }
        },
        { label: '分配人', prop: 'assignorName', width: '120' }
      ],
      columnSelectKefu: [
        { label: '跟进客服', prop: 'customerServiceName', width: '180',
          render: (h, params) => {
            return h(
              'el-select',
              {
                class: 'select-style',
                props: {
                  value: params.row.customerServiceName,
                  size: 'mini',
                  color: params.row.customerServiceStatus == 'S' ? 'red' : ''
                },
                attrs: { filterable: true },
                on: {
                  change: (v) => {
                    params.row.customerServiceName = v
                    this.allocationService(v, params.row)
                    // render函数没有自动更新，需手动强制刷新所以我直接强制刷新了值，而forceUpdate就是重新render。
                    this.$forceUpdate()
                  }
                }
              },
              [
                this.salesAuthorityList.map((val) => {
                  // 下拉框里的内容,reasonList下拉框数据
                  return h('el-option', {
                    props: {
                      value: val.id,
                      label: val.reallyName
                    }
                  })
                })
              ]
            )
          }
        }
      ],
      // 时间  column
      columnTime: [
        { label: '创建时间', prop: 'createdTime', width: '200' },
        {
          label: '订单/资源时间', width: '200',
          render: (h, scope) => {
            return (
              <p>{scope.row.orderTime ? scope.row.orderTime : '-'}</p>
            )
          }
        },
        {
          label: '分配时间', width: '200',
          render: (h, scope) => {
            return (
              <p>{scope.row.assignTime ? scope.row.assignTime : '-'}</p>
            )
          }
        }
      ],
      // 全部
      columnAll: [
        {
          label: '状态', width: '120',
          render: (h, scope) => {
            return (
              <div>
                <el-link size='mini'
                  type={scope.row.assignStatusLabel.indexOf('失败') > -1 ? 'danger' : 'success'}>{scope.row.assignStatusLabel}</el-link>
              </div>
            )
          }
        }
      ],
      // 分配失败
      columnFail: [
        {
          label: '失败原因', width: '240',
          render: (h, scope) => {
            return (
              <div >
                <p style='color:red;cursor:pointer;' title={scope.row.assignErrorLabel} size='mini' onClick={() => { this.onCopyInfoName(scope.row.assignErrorLabelName) }}>{scope.row.assignErrorLabel}</p>
              </div>
            )
          }
        }
      ],
      page: { pageNo: 1, pageSize: 10, totalNum: 0, currentPage: 1 },
      dictionaries: { // 字典数据
        customer_channel_pay_type: [] // 类型
      },
      assignStatusCurrent: 8, // 当前列表状态
      // 分配状态
      assignStatus: {
        all: 8, // 全部
        success: 1, // 分配成功
        distributable: 2, // 未分配 / 可分配
        fail: 3 // 分配失败
      },
      distributionCount: {}, // 未分配客户 / 可分配 - 总数
      userDitchList: [], // 入栈方式、渠道 列表
      salesAuthorityList: [], // 客服列表
      platformList: [], // 平台列表
      orgCodeList: [], // 部门列表
      parArray: [], // 按钮权限
      assignorList: [], // 分配人列表数据
      importDialogVisible: false, // 导入客户弹框
      importDataList: [], // 导入客户列表数据
      importTotal: '',
      uuid: '', // 导入文档的id
      useName: '',
      statistics: '',
      clientCategoryId: '',
      lastTime: 0 // f防抖使用

    }
  },

  created () {
    // 初始表格
    this.column = this.columnCommon.concat(this.columnCompanyPeople).concat(this.columnAll).concat(this.columnOperation).concat(this.columnTime)
    this.search.assignUserId = JSON.parse(sessionStorage.getItem('user_id'))

    this.fetchData()
    this.useName = JSON.parse(sessionStorage.getItem('userInfo'))
    // 获取字典值
    for (const type in this.dictionaries) {
      this.getDictionaries(type)
    }
    this.getSelectCustomerditch()// 渠道列表
    this.getSalesAuthority()// 客服列表
    this.getPlatformList() // 获取平台列表
    this.getOrgTreeList()// 部门列表
    this.getCustomerTaskNumber() // 获取未分配客户 / 可分配 - 总数
    this.getAssignorList()// 获取分配人列表数据
    this.getButtonTreeDto()
    this.getCategoryDate()
    // this.tagGetAllTagDataList()// 获取标签搜索下拉数据
    // this.getAllTagDataList()// 获取人群搜索下拉数据
  },
  mounted () {
    this.$nextTick(() => {
      // 获取本地缓存字典
      const sessionDictionaries = JSON.parse(sessionStorage.getItem('dictionaries'))
      if (sessionDictionaries) {
        this.sessionDictionaries = sessionDictionaries
        // console.log(this.sessionDictionaries)
      }
    })
  },
  activated () {
  },
  watch: {
    filterText (val) {
      this.$refs.allocationTree.filter(val)
    }
  },
  methods: {
    handlerInputNumber () {
      if (this.allocationForm.selectedNum > this.numberPeople) {
        this.$message.warning('输入值不能大于客户数量！')
        this.allocationForm.selectedNum = ''
      }
    },

    // 预估
    handlerEstimate () {
      console.log(this.selectedStaff, 'this.selectedStaff这里是预估的值')
      if (this.selectedStaff.length == 0) {
        this.$message.warning('请勾选需要分配的员工！')
      } else {
        if (this.selectedStaff.findIndex(item => item.assignNum > 0) !== -1) {
          this.handlerPredictNumberInput()
        } else {
          this.handlerPredictNumber()
        }
      }
    },
    // 分配结果查询
    handlerAutoAssign () {
      this.allocation = false
      this.resultDialog = true
      this.loading = true
      const selectedStaff = []
      this.selectedStaff.forEach((item) => {
        const obj = {}
        console.log(item, 'item')
        obj.id = item.id
        obj.assignNum = item.assignNum
        selectedStaff.push(obj)
      })
      const data = {
        assignStatus: this.assignStatusCurrent === 8 ? '' : this.assignStatusCurrent, // 分配状态（1.已分配,2未分配,3分配失败) integer(int32)
        sysUserList: selectedStaff, // 客服信息array
        assignUserId: this.search.assignUserId, // 分配人id integer(int64)
        categoryId: this.search.categoryId, // 类目id integer(int64)
        customerServiceUserId: this.search.customerServiceUserId, // 分配客服 integer(int64)
        endCreateTime: this.search.assignTimeEnd, // string
        goodsName: this.search.goodsName, // 选购商品 string
        keywords: this.search.keywords, // 客户信息 string
        orderNo: this.search.orderNo, // 订单编号 string
        orgCode: this.search.orgCode[this.search.orgCode.length - 1], // 部门编号 string
        pageNo: this.resultDialogPage, // 开始页数 integer(int32)
        pageSize: this.resultDialogPageSize, // 每页记录数 integer(int32)
        payType: this.search.payType, // 类型（字典分组：customer_channel_pay_type） string
        platformId: this.search.platformId, // 来源（平台，数据来源【平台管理】） integer(int64)
        startCreateTime: this.search.assignTimeStart, // string
        userDitch: this.search.userDitch, // 渠道（数据来源【入线渠道设定】） integer(int64)
        checkedNum: this.allocationForm.selectedNum, // 已选数量 integer(int32)
        sysUserIdList: [], // 客服id集合 array
        customerUserIdList: this.tableMultipleSelection, // 客户资源 array
        autoAssignType: this.allocationForm.calculateWay, // 分配计算方式（字典：auto_assign_type）integer(int32)
        groupIdList: this.groupIdList,
        groupTierIdList: this.groupTierIdList,
        tagIdList: this.tagIdList,
        tagTierIdList: this.tagTierIdList,
        batchNumber: this.search.batchNumber, // 批次
        assignCategoryId: this.clientCategoryData // 类目
      }
      this.$api.autoAssign(data).then((res) => {
        if (res.code == 0) {

          // this.tagDataList = res.data
          const startIndex = (this.resultDialogPageNo - 1) * this.resultDialogPageSize
          console.log(startIndex, 'startIndex')
          this.showData = res.data.slice(startIndex, startIndex + this.resultDialogPageSize)
          console.log(this.showData, 'showData')
          this.resultDialogTotal = res.data.length
          this.resultDataList = res.data

          this.loading = false
          this.fetchData()
        } else {
          this.loading = false
          this.fetchData()
        }
      }).catch((err) => {
        console.log(err)
        this.loading = false
        this.allocation = false

      })
    },
    // 分配结果弹框关闭按钮
    handleResultDialog () {
      this.resultDialog = false
    },
    // 预估平均手动分配平均值
    handerArtificial () {
      this.estimateNumberTwo = 0
      this.selectedStaff.forEach((item) => {
        this.estimateNumberTwo = Number(item.showAssignNum) + Number(this.estimateNumberTwo)
      })
      this.numberEstimate = parseInt(Number(this.estimateNumberTwo) / Number(this.selectedStaff.length))
      // console.log(this.numberEstimate, 'this.numberEstimate')
    },
    // 预估输入框有值
    handlerPredictNumberInput () {
      let num = 0
      this.residueNumber = 0// 计算没有手动分配的客服数量
      this.selectedStaff.forEach((item) => {
        item.showAssignNum = Number(item.assignNum)
        if (item.assignNum > 0) {
          num = Number(num) + Number(item.assignNum)
          // const num = this.allocationForm.selectedNum - item.assignNum
        } else if (item.assignNum == 0) {
          this.residueNumber++ // 计算没有手动分配的客服数量
          // console.log(item, '等于0的数量')
        }
        // console.log(num, 'num')
      })

      if (this.selectedStaff && this.totalValue !== 0) {
        if (this.allocationForm.selectedNum) { // 已选数量
          this.estimatesNum = Math.round(this.estimateNumber)
          const selectedNum = this.allocationForm.selectedNum - num// 剩下没有被手动分配的资源数
          // console.log(selectedNum, '剩下没有被手动分配的资源数')
          this.showEstimateNumber = selectedNum / this.residueNumber// 已选数量 / 没有手动分配的客服数量  没有手动分配的客服可分配到的资源数量
          // console.log(this.showEstimateNumber, '没有手动分配的客服可分配到的资源数量')

          if (this.showEstimateNumber % 1 === 0) { // 正整数可以平均分配
            for (let i = 0; i < this.selectedStaff.length; i++) {
              if (this.selectedStaff[i].assignNum == 0) { // 吧等于0的也就是没有手动分配的 按照平均值分配
                this.selectedStaff[i].showAssignNum = this.showEstimateNumber
              }
            }
            this.handerArtificial()// 平均值
          } else if (this.showEstimateNumber < 1) { // 如果分配的平均数量小于1 就取余
            const dd = selectedNum % this.residueNumber
            const arr = this.selectedStaff.filter(item => item.assignNum == 0)
            const noZero = this.selectedStaff.filter(item => item.assignNum != 0)
            for (var j = 0; j < dd; j++) { // 如果资源数除以客服数小于0 ，就取余，吧余数当遍历的索引平均分配，最后一个人分配不到
              arr[j].showAssignNum = 1
            }
            this.selectedStaff = [...noZero, ...arr]
            this.handerArtificial()
          } else if (this.showEstimateNumber > 1 && this.showEstimateNumber % 1 !== 0) { // 一人分配多个资源并且除不尽，
            const aa = selectedNum % this.residueNumber // 吧余数也就是平均分配后剩下的用余数当索引添加剩下的
            const arr = this.selectedStaff.filter(item => item.assignNum == 0)

            const noZero = this.selectedStaff.filter(item => item.assignNum != 0)
            arr.forEach((res) => {
              res.showAssignNum = parseInt(this.showEstimateNumber)// 先取整数
            })
            for (let j = 0; j < aa; j++) { // 如果资源数除以客服数小于0 ，就取余，吧余数当遍历的索引平均分配，最后一个人分配不到
              arr[j].showAssignNum = arr[j].showAssignNum + 1
            }
            this.selectedStaff = [...noZero, ...arr]
            // 预估平均人数开始
            this.handerArtificial()
            // 预估平均人数结束
          }
          const Zero = this.selectedStaff.filter(item => Number(item.assignNum) > 0)
          // console.log(Zero, 'Zero')
          if (Zero.length > 0) {
            this.showDataList = true
            this.selectedStaff.forEach((res) => {
              res.isShow = true
            })
          } else {
            this.showDataList = false
            this.selectedStaff.forEach((res) => {
              res.isShow = false
            })
          }
          this.$forceUpdate()
        } else {
          const selectedNum = this.totalValue - Number(num)// 剩下没有被手动分配的资源数
          // console.log(selectedNum, '剩下没有被手动分配的资源数')
          this.showEstimateNumber = selectedNum / this.residueNumber// 已选数量 / 没有手动分配的客服数量  没有手动分配的客服可分配到的资源数量
          console.log(this.showEstimateNumber, '没有手动分配的客服可分配到的资源数量')
          if (this.showEstimateNumber % 1 === 0) { // 正整数可以平均分配
            for (let i = 0; i < this.selectedStaff.length; i++) {
              if (this.selectedStaff[i].assignNum == 0) { // 吧等于0的也就是没有手动分配的 按照平均值分配
                this.selectedStaff[i].showAssignNum = Number(this.showEstimateNumber)
              }
            }
            this.handerArtificial()
          } else if (this.showEstimateNumber < 1) { // 如果分配的平均数量小于1 就取余
            const dd = selectedNum % this.residueNumber

            const arr = this.selectedStaff.filter(item => item.assignNum == 0)
            const noZero = this.selectedStaff.filter(item => item.assignNum != 0)
            for (let j = 0; j < dd; j++) { // 如果资源数除以客服数小于0 ，就取余，吧余数当遍历的索引平均分配，最后一个人分配不到
              arr[j].showAssignNum = 1
            }
            this.selectedStaff = [...noZero, ...arr]
            this.handerArtificial()
          } else if (this.showEstimateNumber > 1 && this.showEstimateNumber % 1 !== 0) { // 一人分配多个资源并且除不尽，
            const aa = selectedNum % this.residueNumber // 吧余数也就是平均分配后剩下的用余数当索引添加剩下的
            const arr = this.selectedStaff.filter(item => item.assignNum == 0)
            arr.forEach((res) => {
              res.showAssignNum = parseInt(this.showEstimateNumber)// 先取整数
            })
            const noZero = this.selectedStaff.filter(item => item.assignNum != 0)
            for (let j = 0; j < aa; j++) { // 如果资源数除以客服数小于0 ，就取余，吧余数当遍历的索引平均分配，最后一个人分配不到
              arr[j].showAssignNum = arr[j].showAssignNum + 1
            }
            this.selectedStaff = [...noZero, ...arr]
            this.handerArtificial()
          }
          this.$forceUpdate()
        }
        const Zero = this.selectedStaff.filter(item => Number(item.assignNum) > 0)
        // console.log(Zero, 'Zero')
        if (Zero.length > 0) {
          this.showDataList = true
          this.selectedStaff.forEach((res) => {
            res.isShow = true
          })
        } else {
          this.showDataList = false
          this.selectedStaff.forEach((res) => {
            res.isShow = false
          })
        }
        this.$nextTick(() => {
          this.selectedStaff
        })
      } else {
        this.$message.warning('请选择需要分配的员工或核实是否有资源可分配！')
      }
    },
    // 预估已选人均分配数量
    handlerPredictNumber () {
      if (this.selectedStaff && this.totalValue !== 0) {
        if (this.allocationForm.selectedNum) { // 已选数量
          this.estimateNumber = this.allocationForm.selectedNum / this.selectedStaff.length// 已选数量 / 客服数
          console.log(this.estimateNumber, '平均分配的人数')
          this.estimatesNum = Math.round(this.estimateNumber)
          // console.log(this.estimatesNum, 'this.estimatesNum')
          if (this.estimateNumber % 1 === 0) { // 正整数可以平均分配
            for (let i = 0; i < this.selectedStaff.length; i++) {
              this.selectedStaff[i].allocationNum = 0
            }
            for (let i = 0; i < this.selectedStaff.length; i++) {
              this.selectedStaff[i].allocationNum = this.estimateNumber
            }
            // console.log('正整数')
          } else if (this.estimateNumber < 1) { // 如果分配的平均数量小于1 就取余
            const dd = this.allocationForm.selectedNum % this.selectedStaff.length
            // console.log(dd, 'dd')
            for (let i = 0; i < this.selectedStaff.length; i++) {
              this.selectedStaff[i].allocationNum = 0
            }
            for (let i = 0; i < dd; i++) {
              this.selectedStaff[i].allocationNum = 1
            }
          } else if (this.estimateNumber > 1 && this.estimateNumber % 1 !== 0) { // 一人分配多个资源并且除不尽，
            for (let i = 0; i < this.selectedStaff.length; i++) {
              this.selectedStaff[i].allocationNum = 0
            }
            for (let i = 0; i < this.selectedStaff.length; i++) {
              this.selectedStaff[i].allocationNum = parseInt(this.estimateNumber)
            }
            const aa = this.allocationForm.selectedNum % this.selectedStaff.length
            for (let i = 0; i < aa; i++) {
              this.selectedStaff[i].allocationNum = this.selectedStaff[i].allocationNum + 1
            }
          }
          const Zero = this.selectedStaff.filter(item => Number(item.assignNum) > 0)
          // console.log(Zero, 'Zero')
          if (Zero.length > 0) {
            this.showDataList = true
            this.selectedStaff.forEach((res) => {
              res.isShow = true
            })
          } else {
            this.showDataList = false
            this.selectedStaff.forEach((res) => {
              res.isShow = false
            })
          }
          // console.log(this.showDataList, 'this.showDataList')
          this.$forceUpdate()
        } else { // 全部可分配数量
          this.estimateNumber = this.totalValue / this.selectedStaff.length
          this.estimatesNum = Math.round(this.estimateNumber)
          // console.log(this.estimatesNum, 'this.estimatesNum')
          // console.log(this.estimateNumber, 'this.estimateNumber')

          if (this.estimateNumber % 1 === 0) { // 正整数可以平均分配
            for (let i = 0; i < this.selectedStaff.length; i++) {
              this.selectedStaff[i].allocationNum = 0
            }
            for (let i = 0; i < this.selectedStaff.length; i++) {
              this.selectedStaff[i].allocationNum = this.estimateNumber
            }
          } else if (this.estimateNumber < 1) { // 如果分配的平均数量小于1 就取余
            for (let i = 0; i < this.selectedStaff.length; i++) {
              this.selectedStaff[i].allocationNum = 0
            }
            const dd = this.totalValue % this.selectedStaff.length
            // console.log(dd, 'dd')
            for (let i = 0; i < dd; i++) {
              this.selectedStaff[i].allocationNum = 1
              console.log(i)
            }
          } else if (this.estimateNumber > 1 && this.estimateNumber % 1 !== 0) { // 一人分配多个资源并且除不尽，
            for (let i = 0; i < this.selectedStaff.length; i++) {
              this.selectedStaff[i].allocationNum = 0
            }
            for (let i = 0; i < this.selectedStaff.length; i++) {
              this.selectedStaff[i].allocationNum = parseInt(this.estimateNumber)
            }
            const aa = this.totalValue % this.selectedStaff.length
            for (let i = 0; i < aa; i++) {
              this.selectedStaff[i].allocationNum = this.selectedStaff[i].allocationNum + 1
            }
          }

          this.$forceUpdate()
        }
        const Zero = this.selectedStaff.filter(item => Number(item.assignNum) > 0)
        if (Zero.length > 0) {
          this.showDataList = true
          this.selectedStaff.forEach((res) => {
            res.isShow = true
          })
        } else {
          this.showDataList = false
          this.selectedStaff.forEach((res) => {
            res.isShow = false
          })
        }
      } else {
        this.$message.warning('请选择需要分配的员工或核实是否有资源可分配！')
      }
    },
    // 获取分配计算方式的选择值
    handlerSelectedNum (e) {
      console.log(e)
      this.selectedStaff.forEach((res) => {
        res.showAssignNum = 0
        res.allocationNum = 0
      })
      this.getPreAutoAssignInfo()
    },
    // 监听标签下拉数据
    handlerTagDataList (e) {
      const tagIdListA = []
      const tagTierIdListA = []
      e.forEach((item) => {
        tagIdListA.push(item[0])
        tagTierIdListA.push(item[1])
      })
      this.tagIdList = [...new Set(tagIdListA)]
      this.tagTierIdList = [...new Set(tagTierIdListA)]
    },
    // 监听分群下拉数据
    handlerCrowdDataList (e) {
      const groupIdListA = []
      const groupTierIdListA = []
      e.forEach((item) => {
        groupIdListA.push(item[0])
        groupTierIdListA.push(item[1])
      })
      this.groupIdList = [...new Set(groupIdListA)]
      this.groupTierIdList = [...new Set(groupTierIdListA)]
    },
    // 获取标签搜索下拉数据
    tagGetAllTagDataList () {
      const params = {}
      this.$api.tagGetAllTagDataList(params).then((res) => {
        if (res.code == 0) {
          this.tagDataList = res.data
        }
      }).catch((err) => {
        console.log(err)
      })
    },
    // 获取人群搜索下拉数据
    getAllTagDataList () {
      const params = {}
      this.$api.getAllTagDataList(params).then((res) => {
        if (res.code == 0) {
          this.crowdDataList = res.data
        }
      }).catch((err) => {
        console.log(err)
      })
    },
    // 资源列表-自动分配所选客户资源的计算总值
    getPreAutoAssignInfo () {
      const data = {
        assignStatus: this.assignStatusCurrent === 8 ? '' : this.assignStatusCurrent, // 分配状态（1.已分配,2未分配,3分配失败) integer(int32)
        // assignTimeEnd: this.search.assignTimeEnd, // 分配时间结束 string
        // assignTimeStart: this.search.assignTimeStart, // 分配时间开始 string
        assignUserId: this.search.assignUserId, // 分配人id integer(int64)
        categoryId: this.search.categoryId, // 类目id integer(int64)
        customerServiceUserId: this.search.customerServiceUserId, // 分配客服 integer(int64)
        endCreateTime: this.search.assignTimeEnd, // string
        goodsName: this.search.goodsName, // 选购商品 string
        keywords: this.search.keywords, // 客户信息 string
        orderNo: this.search.orderNo, // 订单编号 string
        orgCode: this.search.orgCode[this.search.orgCode.length - 1], // 部门编号 string
        pageNo: this.search.pageNo, // 开始页数 integer(int32)
        pageSize: this.search.pageSize, // 每页记录数 integer(int32)
        payType: this.search.payType, // 类型（字典分组：customer_channel_pay_type） string
        platformId: this.search.platformId, // 来源（平台，数据来源【平台管理】） integer(int64)
        startCreateTime: this.search.assignTimeStart, // string
        userDitch: this.search.userDitch, // 渠道（数据来源【入线渠道设定】） integer(int64)
        checkedNum: this.allocationForm.selectedNum, // 已选数量 integer(int32)
        sysUserIdList: [], // 客服id集合 array
        customerUserIdList: this.tableMultipleSelection, // 客户资源 array
        autoAssignType: this.allocationForm.calculateWay, // 分配计算方式（字典：auto_assign_type）integer(int32)
        groupIdList: this.groupIdList,
        groupTierIdList: this.groupTierIdList,
        tagIdList: this.tagIdList,
        tagTierIdList: this.tagTierIdList,
        batchNumber: this.search.batchNumber // 批次

      }
      if (this.assignStatusCurrent !== this.assignStatus.all) {
        data.assignStatus = this.assignStatusCurrent
      }
      this.$api.getPreAutoAssignInfo(data).then((res) => {
        if (res.code == 0) {
          // console.log(res, '自动分配所选客户资源的计算总值')
          this.numberPeople = res.data.customerNum
          this.totalValue = res.data.totalValue
          this.valueName = res.data.valueName
          this.unit = res.data.unitName
          // this.fetchData()
        }
      }).catch((err) => {
        console.log(err)
      })
    },
    // 自动分配弹框提交
    allocationSubmit (formName) {
      console.log(this.selectedStaff, '\selectedStaff')
      console.log(this.selectDataList, '\selectDataList')
      this.$refs[formName].validate((valid) => {
        if (valid) {
          if (this.selectedStaff) {
            // 获取当前时间的时间戳
            const now = new Date().valueOf()
            const that = this
            // 第一次点击
            if (this.lastTime == 0) {
            this.handlerAutoAssign()
              that.lastTime = now
            } else {
              if ((now - that.lastTime) > 3000) {
                // 重置上一次点击时间，2000是我自己设置的2秒间隔，根据自己的需要更改
                that.lastTime = now
                this.handlerAutoAssign()
                // 添加自己要调用的方法
              } else {
                console.log('不触发')
              }
            }
          } else {
            this.$message.warning('请选择分配客服！')
          }
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    //* *部门选择数据请求**//
    handleNodeClickTwo (data) {
      // console.log(this.orgCodeList, 'this.tree')
      this.orgCode = data.orgCode
      this.staiffDataList(data.orgCode)
      if (this.selectedStaff != 0) {
        const dd = {
          code: this.orgCode,
          length: this.selectedStaff
        }
        this.selectedLength.push(dd)
      }
    },
    // 自动分配多选
    handleAutomaticAllocationAll (val) { // 全选
      this.selectDataList = val
      if (this.selectDataList.length !== 0) {
        this.selectedStaff = [...this.selectDataList]
      } else {
        this.selectedStaff.forEach((item) => {
          this.$nextTick(() => {
            item.allocationNum = 0
          })
        })
        this.selectedStaff = [...this.selectDataList]
      }
      if (this.selectDataList.length == 0) {
        this.estimatesNum = 0
        this.numberEstimate = 0
      }
      // this.handlerPredictNumber()
    },

    handleAutomaticAllocationSelect (val, row) { // 单选
      this.selectDataList = val
      this.selectedStaff = this.selectDataList
      row.allocationNum = 0
      row.assignNum=0

      if (this.selectDataList.length == 0) {
        this.estimatesNum = 0
        this.numberEstimate = 0
      }
    },
    // 关闭自动分配设置弹框
    handleAllocationDialogClose () {
      this.allocation = false
      this.selectedStaff = []
      this.numberEstimate = 0
      this.estimatesNum = 0
      this.$refs.allocation.clearSelection()
      this.allocationForm.selectedNum = ''
    },
    // 自动分配
    automationAllocation () {
      // this.treeAxios()
      this.formTc.username = ''
      this.staiffDataList()
      this.getPreAutoAssignInfo()
      this.numberEstimate = 0
      this.estimatesNum = 0
      this.allocationForm.clientCategory = ''
      this.selectedStaff = []
      this.selectDataList = []
      this.allocation = true
    },
    // 复制电话
    copyInfoPhone (row) {
      const that = this
      const info =
      row.customerPhone == null ? '无' : row.customerPhone
      that.$copyText(info).then(
        function (e) {
          that.$message({
            type: 'success',
            message: '复制成功'
          })
        },
        function (e) {
          that.$message({
            type: 'warning',
            message: '复制失败'
          })
        }
      )
    },
    allocationService (kefuId, row) {
      console.log(row, 'row')
      if (row.categoryName == null) {
        return this.$message.warning('该客户没有类目不能跟进！')
      } else {
        const data = {
          idList: [row.id],
          customerId: kefuId,
          categoryId: row.categoryId,
          flag: 1
        }
        this.$api.customerAllocation(data).then((res) => {
        // console.log(res);
          if (res.code == 0) {
            this.$message.success('分配成功')
            this.fetchData()
          }
        }).catch(err => {
          console.log(err)
        })
      }
    },

    // 批量删除
    batchDelete () {
      if (this.tableMultipleSelection.length != 0) {
        const data = {
          ids: this.tableMultipleSelection
        }
        this.$api.resourceDelete(data).then((res) => {
          if (res.code == 0) {
            this.$message({
              type: 'success',
              message: '删除成功!'
            })
            this.fetchData()
          }
        }).catch((err) => {
          console.log(err)
        })
      } else {
        this.$message.warning('请勾选需要删除的数据！')
        return
      }
    },
    resourceFeedback () {
      // const ids = []
      // if (this.tableMultipleSelection.length != 0) {
      //   this.tableMultipleSelection.forEach((item) => {
      //     ids.push(item.id)
      //   })
      // }
      let data = {
        pageNo: this.page.pageNo,
        pageSize: this.page.pageSize
      }
      const search = this.search
      data = Object.assign(data, search)
      if (data.orgCode) {
        data.orgCode = search.orgCode[search.orgCode.length - 1]
      }
      data.assignStatus = this.assignStatusCurrent
      if (data.assignStatus == 8) {
        data.assignStatus = ''
      }
      if (data.assignTimeEnd === '' || data.assignTimeStart === '') {
        return this.$message.warning('请选择时间！')
      }
      if (this.search.orgCode.length === 0) {
        console.log(this.search.orgCode)
        return this.$message.warning('请选择公司部门！')
      }
      this.$api.resourceFeedback(data).then((res) => {
        console.log(res, 'res')
        if (res.code == 0) {
          this.downloadlink(res.data)
          this.$message.success('操作成功！')
          this.dialog.visible = false
          this.fetchData('search')
        }
      }).catch((err) => {
        console.log(err)
      })
    },
    // 删除
    resourceDelete (row) {
      // const ids = []
      // if (this.tableMultipleSelection.length != 0) {
      //   this.tableMultipleSelection.forEach((item) => {
      //     ids.push(item.id)
      //   })
      // }
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        const data = {
          ids: [row.id]
        }
        this.$api.resourceDelete(data).then((res) => {
          if (res.code == 0) {
            this.$message({
              type: 'success',
              message: '删除成功!'
            })
            this.fetchData()
          }
        }).catch((err) => {
          console.log(err)
        })
      }).catch(() => {

      })
      console.log(row)
    },
    // 指派弹框选择类目
    handleClientCategory (e) {
      this.clientCategoryId = e[e.length - 1]
    },
    // 自动分配类目选择
    selectClientCategory (e) {
      if (e.length === 2) {
        this.clientCategoryData = e[e.length - 1]
      } else {
        this.$message.warning('只能选择二级类目！')
        this.$nextTick(() => {
          this.allocationForm.clientCategory = ''
          this.$refs['cascade'].panel.clearCheckedNodes()
        })
      }
    },
    // 类目数据
    getCategoryDate () {
      const params = {
        pageSize: 10000
      }
      this.$api.categoryCascadeDate(params).then((res) => {
        if (res.code == 0) {
          this.categoryOptions = res.data
        }
      }).catch((err) => {
        console.log(err)
      })
    },
    handleChangeSearch (e) {
      this.search.categoryId = e[e.length - 1]
    },
    // 分配弹框内列表单选
    getCurrentRow (row) {
      this.serviceId = row.id
    },
    fetchData (type) {
      this.loading = true
      if (type == 'reset') {
        this.search.assignTimeStart = ''
        this.search.assignTimeEnd = ''
        this.search = {
          orderNo: '', // 否 	string 	订单编号
          keywords: '', // 否 	string 	客户信息
          goodsName: '', // 否 	string 	选购商品
          userDitch: '', // 否 	string 	渠道（数据来源【入线渠道设定】）
          platformId: '', // 是 	int 	来源平台id
          orgCode: [], // 否 	string 	部门编号
          assignTimeStart: '', // 否 	String 	分配时间开始
          assignTimeEnd: '', 	// 否 	String 	分配时间结束
          payType: '', // 否 	string 	类型（字典分组：customer_channel_pay_type）
          assignUserId: '', // 否 	string 	分配人id
          categoryId: '',
          customerServiceUserId: '',
          tags: '',
          crowds: '',
          batchNumber: '' // 批次

        }
        this.date = []
        this.page.pageNo = 1
        this.page.pageSize = 10
        this.page.currentPage = 1
        this.createDate = []
        this.assignStatusCurrent = this.assignStatus.all
      }
      const params = {
        pageNo: this.page.pageNo,
        pageSize: this.page.pageSize,
        orderNo: this.search.orderNo, // 否 	string 	订单编号
        keywords: this.search.keywords, // 否 	string 	客户信息
        goodsName: this.search.goodsName, // 否 	string 	选购商品
        userDitch: this.search.userDitch, // 否 	string 	渠道（数据来源【入线渠道设定】）
        platformId: this.search.platformId, // 是 	int 	来源平台id
        orgCode: this.search.orgCode[this.search.orgCode.length - 1], // 否 	string 	部门编号
        startCreateTime: this.search.assignTimeStart, // 否 	String 	创建时间开始
        endCreateTime: this.search.assignTimeEnd, 	// 否 	String 	创建时间结束
        payType: this.search.payType, // 否 	string 	类型（字典分组：customer_channel_pay_type）
        assignUserId: this.search.assignUserId, // 否 	string 	分配人id
        categoryId: this.search.categoryId, // 类目Id
        customerServiceUserId: this.search.customerServiceUserId, // 分配客服
        batchNumber: this.search.batchNumber, // 批次
        groupIdList: this.groupIdList,
        groupTierIdList: this.groupTierIdList,
        tagIdList: this.tagIdList,
        tagTierIdList: this.tagTierIdList

      }
      if (this.assignStatusCurrent !== this.assignStatus.all) {
        params.assignStatus = this.assignStatusCurrent
      }

      if (type == 'search') {
        // let params = {
        //   pageNo: 1,
        //   pageSize: 10
        // }
        // params = Object.assign(params, this.search);
        params.pageNo = 1
        params.pageSize = 10
        this.page.pageSize = 10
        params.orgCode = this.search.orgCode[this.search.orgCode.length - 1]
        params.groupIdList = this.groupIdList
        params.groupTierIdList = this.groupTierIdList
        params.tagIdList = this.tagIdList
        params.tagTierIdList = this.tagTierIdList
        // 去除字符串 前后 空格
        for (const item in params) {
          if (typeof params[item] === 'string') {
            params[item] = params[item].trim()
          }
        }
      }
      console.log(this.page.pageSize, 'this.page.pageSize')
      this.$api.customerAssignPageList(params).then((res) => {
		console.log(res);
        this.list = res.data.list
		this.list.forEach(item=>{
			// console.log(item.prodName)
			if(item.prodName && item.prodName.indexOf('<br/>') > -1){
				item.prodName = item.prodName.replace('<br/>','')
			}
      if (item.assignErrorLabel && item.assignErrorLabel.indexOf('此类目已被其他人跟进') > -1){
        let tempName = item.assignErrorLabel.substr(11)
        let endIndex = item.assignErrorLabel.indexOf('/');
        if(endIndex > -1) {
          tempName = tempName.substr(0,endIndex)
        }
        const reg = /[\u4e00-\u9fa5]+/g;
        item.assignErrorLabelName = tempName.match(reg)[0]
        console.log(item.assignErrorLabelName)
      }
      if (item.assignErrorLabel && item.assignErrorLabel.indexOf('该客户类目已经被其他客服跟进') > -1){
        let tempName = item.assignErrorLabel.substr(15)
        let endIndex = item.assignErrorLabel.indexOf('/');
        if(endIndex > -1) {
          tempName = tempName.substr(0,endIndex)
        }
        const reg = /[\u4e00-\u9fa5]+/g;
        item.assignErrorLabelName = tempName.match(reg)[0]
        console.log(item.assignErrorLabelName)
      }
		})
        this.page.totalNum = res.data.totalNum
        this.loading = false
      }).catch((err) => {
        this.loading = false
        console.log(err)
      })
    },
    handleCurrentChange (currentChange) {
      this.page.pageNo = currentChange
      this.fetchData()
    },
    handleSizeChange (sizeChange) {
      this.page.pageSize = sizeChange
      this.fetchData()
    },
    onCopyInfoName (info) {
      if (info === undefined) {return}
      const t = this
      this.$copyText(info).then(
          function (e) {
            t.$message({
              type: 'success',
              message: '复制成功'
            })
          },
          function (e) {
            t.$message({
              type: 'warning',
              message: '复制失败'
            })
          }
      )
    },
    getButtonTreeDto () {
      // 获取权限设定
      this.limits = JSON.parse(sessionStorage.getItem('limit'))
      const params = this.limits.buttonTreeDto.filter(
        (item) => item.menuCode === 'customersList'
      )
      params[0].buttonList.forEach((item) => {
        this.parArray.push(item.code)
      })
    },
    // 获取字典数据
    getDictionaries (type) {
      if (type && this.dictionaries[type].length > 0) {
        return
      }
      const params = { groupId: type }
      this.$api.dictionaries(params).then((res) => {
        this.dictionaries[type] = res.data
      }).catch((err) => {
        console.log(err)
      })
    },
    // // 选择时间
    // onChangeDate (e) {
    //   this.search.assignTimeStart = e[0]
    //   this.search.assignTimeEnd = e[1]
    // },
    // 选择创建时间
    onChangeCreate (e) {
      if (e) {
        this.search.assignTimeStart = e[0]
        this.search.assignTimeEnd = e[1]
      } else {
        this.search.assignTimeStart = ''
        this.search.assignTimeEnd = ''
      }
    },
    // 切换 tab 未分配客户11分配失败分配成功
    handleClick (val) {
    },
    // 渠道列表
    getSelectCustomerditch (type) {
      this.$api.selectCustomerditch().then((res) => {
        this.userDitchList = res.data
      }).catch((err) => {
        console.log(err)
      })
    },
    // 客服列表
    getSalesAuthority () {
      const params = { salesAuthorityId: JSON.parse(sessionStorage.getItem('salesAuthorityId').split(',')) }
      this.$api.salesAuthority(params).then((res) => {
        this.salesAuthorityList = res.data
      }).catch((err) => {
        console.log(err)
      })
    },
    // 获取平台列表
    getPlatformList () {
      const params = {}
      this.$api.platformDataList(params).then((res) => {
        this.platformList = res.data
      }).catch((err) => {
        console.log(err)
      })
    },
    // 部门列表
    getOrgTreeList (type) {
      const params = { request: { orgName: '', orgType: '' }, version: '' }
      this.$api.orgTreeList(params).then((res) => {
        this.orgCodeList = res.data
        this.loopOrgCode(res.data)
      }).catch((err) => {
        console.log(err)
      })
    },
    loopOrgCode (orgCodeArr, selectedArr) {
      const orgArr = orgCodeArr
      const selArr = selectedArr
      if (selectedArr) {
        orgArr.forEach(item => {
          item.selectedList = []
          if (item.children) { this.loopOrgCode(item.children) }
        })
        selArr.forEach(sitem => { // 已选择
          orgArr.forEach(item => { // 公司部门
            if (item.orgCode === sitem.orgCode) {
              item.selectedList.push(sitem)
            }
            // item.selectedList = Array.from(new Set(item.selectedList))
            item.selectedList = [...new Set(item.selectedList)]
            // console.log(orgArr[0].orgName, orgArr)
            if (item.children) { this.loopOrgCode(item.children, selArr) }
          })
        })
      } else {
        orgArr.forEach(item => {
          item.selectedList = []
          if (item.children) { this.loopOrgCode(item.children) }
        })
      }
      this.orgCodeList = [...orgArr]
    },
    // 分配人列表
    getAssignorList (type) {
      const params = {}
      this.$api.assignorList(params).then((res) => {
        this.assignorList = res.data
		let isUser = false
		res.data.forEach(item=>{
			if(this.search.assignUserId == item.id){

			}else{
				isUser = true;
			}
		})
		if(isUser){
			this.assignorList.push({id:this.search.assignUserId,reallyName:JSON.parse(sessionStorage.getItem('userInfo')).reallyName})
		}
		// console.log()
		// console.log(this.search.assignUserId,res.data)
      }).catch((err) => {
        console.log(err)
      })
    },
    // 获取未分配客户 / 可分配 - 总数
    getCustomerTaskNumber () {
      const params = {}
      this.$api.customerTaskNumber(params).then((res) => {
        this.distributionCount = res.data
      }).catch((err) => {
        console.log(err)
      })
    },
    // 切换当前列表
    onChangeAssignStatus (state) {
      // this.form = Object.assign({}, {})
      this.assignStatusCurrent = state
      if (this.assignStatusCurrent === this.assignStatus.all) {
        this.column = this.columnCommon.concat(this.columnCompanyPeople).concat(this.columnAll).concat(this.columnTime).concat(this.columnOperation)
      }
      if (this.assignStatusCurrent === this.assignStatus.distributable) {
        this.column = this.columnCommon.concat(this.columnTime).concat(this.columnOperation)
      }
      if (this.assignStatusCurrent === this.assignStatus.fail) { // 分配失败
        this.column = this.columnCommon.concat(this.columnCompanyPeople).concat(this.columnFail).concat(this.columnTime).concat(this.columnOperation)
        this.column.splice(11, 1, this.columnSelectKefu[0])
      }
      // if(this.assignStatusCurrent === this.assignStatus.success ) { this.column = columnCommon.concat(columnSuccess).concat(columnOperation) }
      if (this.assignStatusCurrent === this.assignStatus.success) {
        this.column = [...this.columnCommon, ...this.columnCompanyPeople, ...this.columnTime, ...this.columnOperation]
      }

      this.page.pageNo = 1
      this.page.pageSize = 10
      this.page.currentPage = 1
      this.fetchData()
    },
    // 客户导入
    importClient () {
      this.leadingInLive = true
    },
    // 客户导入关闭
    handleDialogClose () {
      this.leadingInLive = false
      this.logFile1 = ''
      this.$refs['tops'].clearFiles()// 清空导入数据
    },
    orderImportLive (fileObj) {
      const formData = new FormData()
      formData.append('file', fileObj.file)
      this.logFile1 = formData
    },
    // 一键导入
    templateMode () {
      console.log(this.logFile1, 'logFile1')
      if (this.logFile1 == '' || this.logFile1 == undefined) {
        return this.$message.warning('请上传文件后再确定~')
      }
      this.leadingInLive = false
      this.$refs.tops.clearFiles()
      const config = {
        headers: {
          'Content-Type': 'multipart/form-data'
        },
        timeout: 120000
      }
      this.axios
        .post(
          '/order/v1/customer/channel/one/key/custoemr/import',
          this.logFile1,
          config
        )
        .then((res) => {
          if (res.code == 0) {
            this.importDialogVisible = true
            this.importDataList = []
            this.logFile1 = ''
            this.getImportList(res.data.uuid)
            this.uuid = res.data.uuid
            // this.importTotal = res.data.
            // this.guideId = ""; //清空模板下拉框
            // this.$alert(
            //   "导入成功的数量: " +
            //   res.data.successNumber +
            //   "条, " +
            //   "导入失败的数量: " +
            //   res.data.errorNumber +
            //   "条",
            //   "提示",
            //   {
            //     confirmButtonText: "确定",
            //   }
            // );
            if (res.data.errorUrl) {
              const url = this.ImgHttps + res.data.errorUrl // 创建下载链接
              const link = document.createElement('a') // 创建a标签
              link.style.display = 'none' // 将a标签隐藏
              link.href = url // 给a标签添加下载链接
              link.setAttribute('download', '统一模板') // 此处注意，要给a标签添加一个download属性，属性值就是文件名称 否则下载出来的文件是没有属性的，空白白
              document.body.appendChild(link)
              link.click() // 执行a标签
            }
            if (res.data.errorURI) {
              const url = this.ImgHttps + res.data.errorURI // 创建下载链接
              const link = document.createElement('a') // 创建a标签
              link.style.display = 'none' // 将a标签隐藏
              link.href = url // 给a标签添加下载链接
              link.setAttribute('download', '统一模板') // 此处注意，要给a标签添加一个download属性，属性值就是文件名称 否则下载出来的文件是没有属性的，空白白
              document.body.appendChild(link)
              link.click() // 执行a标签
            }
            this.fetchData()
          } else {
            this.$message.error(res.message)
          }
        })
        .catch()
    },
    handleSizeImport (e) {
      this.importPageSize = e
      this.getImportList(this.uuid)
    },
    handleCurrentImport (e) {
      this.importPage = e
      this.getImportList(this.uuid)
    },
    // 查询导人成功后的弹窗数据
    getImportList (uuid) {
      const data = {
        uuid: uuid,
        pageNo: this.importPage,
        pageSize: this.importPageSize
      }
      this.$api.customerImport(data).then((res) => {
        if (res.code == 0) {
          this.importDataList = res.data.pageResponse
          this.statistics = res.data
        }
      }).catch((err) => {
        console.log(err)
      })
    },
    // 下载模板
    DownloadTemplate () {
      // this.downloadlink('https://5eck-down.oss-cn-shenzhen.aliyuncs.com/v1.2.0%E7%BB%9F%E4%B8%80%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx')
      // this.downloadlink('https://fenxiao.muruji.com/v1.2.0%E7%BB%9F%E4%B8%80%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx')
      const export_model_url = this.sessionDictionaries.export_model_url
      const modelIndex = export_model_url.findIndex(item => {
        return item.dictId === 'customer_user_import_model'
      })
      // this.downloadlink('https://5eck-down.oss-cn-shenzhen.aliyuncs.com/model/五域v1.2.2导入导出文件模板/%E5%AF%BC%E5%85%A5%E7%89%A9%E6%B5%81%E5%8D%95%20-%20%E6%88%90%E5%8A%9F.xls?versionId=CAEQJxiBgMDOsa_kgxgiIDEwNTJhMTVmZTgyYTQ1MzE4NmRjYmQ0ZjFjZTk4MDg2')
      this.downloadlink(export_model_url[modelIndex].dictName)
    },
    handleSelectionChange (val) {
      const ids = []
      if (val.length) {
        for (let i = 0; i < val.length; i++) {
          ids.push(val[i].id)
        }
      }
      this.tableMultipleSelection = ids
      // console.log(this.tableMultipleSelection, '选择了几个')
    },
    onDetail (row, index) {
      // this.ruleForm.clientCategory = ''
      // this.clientCategoryId = ''
      if (this.parArray.indexOf('allocation') != -1) {
        this.serviceId = ''
        this.multipleSelection = ''
        if (index == 1) {
          if (this.tableMultipleSelection.length != 0) {
            this.$message.warning('选择了多个客户请使用批量分配！')
          } else {
            this.treeAxios()
            this.dialog.title = '分配'
            this.selectionCustomer = row.id
            this.dialog.visible = true
            this.$refs['ruleForm'].clearValidate()
          }
        } else {
          if (this.tableMultipleSelection.length == 0) {
            this.$message.warning('请选择需要分配的客户')
          } else {
            this.treeAxios()
            this.dialog.title = '批量分配'
            this.dialog.visible = true
            this.$refs['ruleForm'].clearValidate()
          }
        }
      } else {
        this.$message.warning('没有权限请联系管理员！')
      }
    },
    treeAxios (e) {
      if (e == 1) {
        this.stafpage = 1
        // this.stafPageSize = 10;
      }
      if (e == 2) {
        this.stafpage = 1
        this.stafPageSize = 10
        this.formTc.username = ''
      }
      this.axios
        .post('/sys/v1/org/tree/select', {
          request: {
            orgName: '',
            status: ''
          },
          version: ''
        })
        .then((res) => {
          if (res.code == 0) {
            this.tree = res.data
            this.staiffList(res.data[0].orgCode)
          }
        })
    },
    staiffDataList (orgCode) {
      this.allocationLoading = true
      this.axios
        .post(
          '/sys/v1/user/employee/list',
          {
            request: {
              endTime: '',
              keyWord: this.formTc.username,
              orgCode: orgCode,
              pageNo: this.stafpage,
              pageSize: this.stafPageSize,
              phoneNumber: '',
              positionCode: '',
              reallyName: '',
              startTime: '',
              status: 'A',
              username: ''
            },
            version: ''
          },
          {
            headers: {
              isLoading: false
            }
          }
        )
        .then((res) => {
          if (res.code === 0) {
            this.tablePerson = []
            this.staffTableList = []

            res.data.list.forEach((item) => {
              item.allocationNum = 0
              item.assignNum = 0
              item.showAssignNum = 0
              item.isState = false
            })
            this.staffTableList = res.data
            // this.selectedStaff：实际用来计算平均值的数组
            // this.selectDataList：表格选中的数据
            this.selectedStaff = this.selectDataList // 吧之前选中的数据在翻页后再赋值一遍，不然获取不到表格内输入框的值
            if (this.selectedStaff.length !== 0) { // 吧之前选中和填写的值在翻页后回显
              // res.data.list.forEach((item) => {
              //   this.selectedStaff.forEach((res) => {
              //     if (item.id === res.id) {
              //       this.$nextTick(() => {
              //         item.allocationNum = res.allocationNum
              //         item.assignNum = res.assignNum
              //         item.showAssignNum = res.showAssignNum
              //       })
              //     }
              //   })
              // })
              this.staffTableList.list = this.staffTableList.list.map((item) => {
                const k = this.selectedStaff.findIndex((v) => v.id === item.id)
                console.log(k, 'k')
                if (k !== -1) {
                  return this.selectedStaff[k]
                }else{
                  return{
                    ...item,
                  allocationNum:0,
                  assignNum:0,
                  showAssignNum:0
                  }

                }
                // this.selectedStaff.forEach((res) => {
                //   if (item.id === res.id) {
                //     return {
                //       item.allocationNum: res.allocationNum
                //       item.assignNum : res.assignNum
                //       item.showAssignNum : res.showAssignNum
                //     }
                //   }
                // })
              })
              console.log(res.data, 'res.data')
            }
            // this.$nextTick(() => {
            //   const select = this.selectedStaff
            //   this.selectedStaff = select
            // })
            console.log(this.selectedStaff, 'this.selectedStaff这是翻页之后的选中值')

            this.$forceUpdate()
            this.allocationLoading = false
          } else {
            this.$message.error(res.message)
            this.allocationLoading = false
          }
        })
    },
    /** *员工列表***/
    staiffList (orgCode) {
      this.allocationLoading = true
      this.axios
        .post(
          '/sys/v1/user/employee/list',
          {
            request: {
              endTime: '',
              keyWord: this.formTc.username,
              orgCode: orgCode,
              pageNo: this.stafpage,
              pageSize: this.stafPageSize,
              phoneNumber: '',
              positionCode: '',
              reallyName: '',
              startTime: '',
              status: 'A',
              username: ''
            },
            version: ''
          },
          {
            headers: {
              isLoading: false
            }
          }
        )
        .then((res) => {
          if (res.code === 0) {
            this.tablePerson = []

            // res.data.list.forEach((item) => {
            //   item.allocationNum = 0
            //   item.assignNum = 0
            //   item.showAssignNum = 0
            //   item.isState = false
            // })
            // this.selectedStaff：实际用来计算平均值的数组
            // this.selectDataList：表格选中的数据
            // this.selectedStaff = this.selectDataList // 吧之前选中的数据在翻页后再赋值一遍，不然获取不到表格内输入框的值
            // if (this.selectedStaff.length !== 0) { // 吧之前选中和填写的值在翻页后回显
            //   res.data.list.forEach((item) => {
            //     this.selectedStaff.forEach((res) => {
            //       if (item.id === res.id) {
            //         this.$nextTick(() => {
            //           item.allocationNum = res.allocationNum
            //           item.assignNum = res.assignNum
            //           item.showAssignNum = res.showAssignNum
            //         })
            //       }
            //     })
            //   })
            //   console.log(res.data, 'res.data')
            // }
            // this.$nextTick(() => {
            //   const select = this.selectedStaff
            //   this.selectedStaff = select
            // })
            console.log(this.selectedStaff, 'this.selectedStaff这是翻页之后的选中值')

            this.tablePerson = res.data
            this.allocationLoading = false
          } else {
            this.$message.error(res.message)
            this.allocationLoading = false
          }
        })
    },
    //* *数据请求**//
    handleNodeClick (data) {
      console.log(data.orgCode)
      this.orgCode = data.orgCode
      this.staiffList(data.orgCode)
    },

    filterNode (value, data) {
      if (!value) return true
      return data.orgName.indexOf(value) !== -1
    },
    getRowKey (row) {
      return row.id
    },
    getRowKeyTWO (row) {
      return row.id
    },
    // 自动分配分页
    handleSizeEmplay (val) {
      this.stafPageSize = val
      this.staiffList(this.orgCode)
    },
    handleCurrentEmplayNew (val) {
      this.stafpage = val
      this.staiffDataList(this.orgCode)
      // this.handlerEstimate()
    },
    // 自动分配分页结束
    handleSizeEmplayNew (val) {
      this.stafPageSize = val
      this.staiffDataList(this.orgCode)
    },
    //* * 普通数据请求 **//
    // 弹出层分页
    handleCurrentEmplay (val) {
      this.stafpage = val
      this.staiffList(this.orgCode)
    },
    handleSizeAllocation (val) {
      console.log(val, '弹出层分页1')
      this.resultDialogPageSize = val
      // this.handlerAutoAssign()
    },
    //* * 普通数据请求 **//
    // 弹出层分页
    handleCurrentAllocation (val) { // 手动分页
      this.resultDialogPageNo = val
      // this.tagDataList = res.data
      const startIndex = (this.resultDialogPageNo - 1) * this.resultDialogPageSize
      console.log(startIndex, 'startIndex')
      this.showData = this.resultDataList.slice(startIndex, startIndex + this.resultDialogPageSize)
      console.log(startIndex, startIndex + this.resultDialogPageSize, 'startIndex, startIndex + this.resultDialogPageSize')
      // this.handlerAutoAssign()
    },
    // 分页数据处理
    personnelPaging () {
      this.total > (this.pageNum - 1) * this.pageSize ? '' : this.pageNum--
      const arr = this.arr.slice(
        (this.pageNum - 1) * this.pageSize || 0,
        this.pageNum * this.pageSize
      )
      this.total = this.arr.length
      this.currentPagingData = arr
    },

    // 分配客户成功
    submission: _.debounce(function (formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          if (this.dialog.title === '批量分配') {
            const data = {
              idList: this.tableMultipleSelection,
              customerId: this.serviceId,
              categoryId: this.clientCategoryId
            }
            const that = this
            // 获取当前时间的时间戳
            const now = new Date().valueOf()
            if (this.lastTime === 0) {
              this.$api.customerAllocation(data).then((res) => {
                // console.log(res);
                if (res.code === 0) {
                  if (res.data > 0) {
                    this.$message.success('分配成功' + res.data + '条')
                    this.fetchData()
                    this.dialog.visible = false
                    this.$refs.multipleTable.clearSelection()
                  } else {
                    this.dialog.visible = false
                    this.$message.error(res.message)
                  }
                } else {
                  this.dialog.visible = false
                }
              }).catch(err => {
                console.log(err)
              })
              that.lastTime = now
            } else {
              if ((now - that.lastTime) > 3000) {
                // 重置上一次点击时间，2000是我自己设置的2秒间隔，根据自己的需要更改
                that.lastTime = now
                this.$api.customerAllocation(data).then((res) => {
                // console.log(res);
                  if (res.code === 0) {
                    if (res.data > 0) {
                      this.$message.success('分配成功' + res.data + '条')
                      this.fetchData()
                      this.dialog.visible = false
                      this.$refs.multipleTable.clearSelection()
                    } else {
                      this.dialog.visible = false
                      this.$message.error(res.message)
                    }
                  } else {
                    this.dialog.visible = false
                  }
                }).catch(err => {
                  console.log(err)
                })
              } else {
                console.log('不触发')
              }
            }
          } else {
            const data = {
              idList: [this.selectionCustomer],
              customerId: this.serviceId,
              categoryId: this.clientCategoryId
            }
            const that = this
            // 获取当前时间的时间戳
            const now = new Date().valueOf()
            if (this.lastTime === 0) {
              this.$api.customerAllocation(data).then((res) => {
                if (res.code === 0) {
                  // console.log(res);
                  if (res.data > 0) {
                    this.$message.success('分配成功')
                    this.fetchData()
                    this.dialog.visible = false
                    this.$refs.multipleTable.clearSelection()
                  } else {
                    this.dialog.visible = false
                    this.$message.error('分配失败')
                  }
                } else {
                  this.dialog.visible = false
                }
              }).catch(err => {
                console.log(err)
              })
              that.lastTime = now
            } else {
              if ((now - that.lastTime) > 3000) {
                // 重置上一次点击时间，2000是我自己设置的2秒间隔，根据自己的需要更改
                that.lastTime = now
                this.$api.customerAllocation(data).then((res) => {
                  if (res.code === 0) {
                    // console.log(res);
                    if (res.data > 0) {
                      this.$message.success('分配成功')
                      this.fetchData()
                      this.dialog.visible = false
                      this.$refs.multipleTable.clearSelection()
                    } else {
                      this.dialog.visible = false
                      this.$message.error('分配失败')
                    }
                  } else {
                    this.dialog.visible = false
                  }
                }).catch(err => {
                  console.log(err)
                })
              } else {
                console.log('不触发')
              }
            }
          }
        } else {
          console.log('error submit!!')
          return false
        }
      })
    }, 300),
    toInformation (row) {
      this.$router.push({
        name: 'customerInformation',
        query: {
          id: row.customerId,
          navName: 1,
          uid: row.id
        }
      })
    },
    // 复制
    copyInfo (row) {
      const that = this
      // let inline = this.line.find((res) => res.id == row.userDitch);
      const info =
          '订单编号：' +
          (row.orderNo == null ? '无' : row.orderNo) +
          '\n' +
          '渠道：' +
          (row.channelName == null ? '无' : row.channelName) +
          '\n 客户姓名：' +
          (row.customerName == null ? '无' : row.customerName) +
          '\n' +
          '电话：' +
          (row.customerPhone == null ? '无' : row.customerPhone) +
          '\n 入线时间：' +
          (row.orderTime == null ? '无' : row.orderTime) +
          '\n' +
          '商品名称：' +
          (row.prodName == null ? '无' : row.prodName) +
          '\n' +
          '单价：' +
          (row.prodPrice == null ? '无' : row.prodPrice) +
          '\n' +
          '规格：' +
          (row.prodItem == null ? '无' : row.prodItem) +
          '\n' +
          '商品数量：' +
          (row.prodNumber == null ? '无' : row.prodNumber) +
          '\n' +
          '商品总价：' +
          (row.totalMoney == null ? '无' : row.totalMoney) +
          '\n' +
          '收货地址：' +
          (row.postAddress == null ? '无' : row.postAddress) +
          '\n' +
          '支付类型：' +
          (row.payTypeLabel == null ? '无' : row.payTypeLabel) +
          '\n' +
          '留言：' +
          (row.customerMessage == null ? '无' : row.customerMessage)
      that.$copyText(info).then(
        function (e) {
          that.$message({
            type: 'success',
            message: '复制成功'
          })
        },
        function (e) {
          that.$message({
            type: 'warning',
            message: '复制失败'
          })
        }
      )
    }
  }
  // 跳转客户资料

}
</script>

<style scoped lang="scss">
.div1,
.div2,
.div3 {
  width: 120px;
  height: 30px;
  text-align: center;
  line-height: 30px;
  color: #2d7edf;
}

.div1,
.div2 {
  margin-left: -16px;
}

.div1,
.div3 {
  color: #2d7edf;
}

.div1 {
  background: url(../../assets/breadcrumb2.png);
}

.div2 {
  background: url(../../assets/breadcrumb1.png);
  color: #fff;
}

.div3 {
  margin-left: -8px;
  background: url(../../assets/breadcrumb3.png);
}

.search-form {
  display: flex;
  flex-wrap: wrap;

  .el-form-item {
    width: 100%;
    max-width: 303px;
    min-width: 299px;

    /deep/ .el-form-item__label {
      width: 70px;
    }

    /deep/ .el-form-item__content {
      width: calc(100% - 70px);

      .el-select, .el-date-editor, .el-cascader {
        width: 100%;
      }
    }
  }
}

.content {
  margin-bottom: 20px;
  padding: 20px;
  background-color: #ffffff;

  .btn-list {
    width: 100%;
    display: flex;
    justify-content: space-between;
    margin: 10px 0;

    .el-button {
      min-width: 128px;
      height: 36px;
      font-size: 16px;
      border: none;
    }

    div:nth-child(2) {
      button:first-child {
        color: #409EFF;
        border: 1px solid #409EFF;
      }
    }

    //.el-button--primary.is-plain{
    //  color: #000000;
    //  &:hover, &:hover {
    //    color: #ffffff;
    //  }
    //}

    .el-button--default {
      border: 0;
      color: #2d7edf;
    }
  }
}

.treeAllocation {
  height: 636px;
  border: 1px solid #E8EAEC;
  overflow-y: scroll;

  /deep/ .el-input__inner {
    width: 89%;
    height: 28px;
    line-height: 28px;
    margin: 12px;

  }
  /deep/.el-input__icon{
    margin-left: 10px;
  }
}
.tree {
  height: 600px;
  overflow-y: scroll;
  width: 250px;
  float: left;

  /deep/.el-input__inner {
    width: 200px;
    height: 28px;
    line-height: 28px;
  }
}
/deep/ .el-dialog__body {
  padding: 15px 20px;
  color: #606266;
  font-size: 14px;
  word-break: break-all;
}

/deep/ .el-dialog__header {
  padding: 10px 20px 10px;

  .el-dialog__title {
  }
}

.table2 {
  height: 500px;
  overflow-y: scroll;
  border: 1px solid #E8EAEC;

  /deep/ .el-input__inner {
    width: 100px;
    height: 28px;
    line-height: 28px;
  }
}
.table1 {
  display: inline-block;
  height: 500px;
  margin-left: 15px;
  width: 740px;
  overflow-y: scroll;

  /deep/ .el-input__inner {
    width: 100px;
    height: 28px;
    line-height: 28px;
  }
}
/deep/ .el-dialog {
  position: relative;
  margin: 0 auto 50px;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  box-sizing: border-box;
  width: 1052px;
  // height: 700px;
  z-index: 1000;
}

/deep/ .el-dialog__headerbtn {
  top: 15px;
}

/deep/ .el-dialog__headerbtn .el-dialog__close {
  color: #fff;
}

.statistics {
  background-color: #edf2fd;
  padding: 11px 14px;
  display: flex;
  margin-bottom: 36px;
  margin-top: 10px;

  .statistics_item {
    padding-right: 32px;
    font-size: 16px;
    font-family: PingFang SC;
    font-weight: bold;
    line-height: 22px;
    color: #4c81eb;
  }
}

/deep/ .el-table thead {
  font-size: 16px;
  font-family: PingFang SC;
  font-weight: bold;
  line-height: 22px;
  color: #333333;
  opacity: 1;
}

/deep/ .el-table__header-wrapper {
  background-color: red;
}
.classRed{
  color:red !important;
}
.dialog {
  /deep/ .el-dialog__body {
    height: 500px;
    overflow: scroll;
  }
}

/deep/.el-scrollbar{
  height:10px;
}
/deep/.el-scrollbar__bar.is-horizontal{
  height: 9px;

}
/deep/.el-table__row td .cell span, /deep/.el-table__row td .cell div p{
  display: block;
  overflow : hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;      /* 可以显示的行数，超出部分用...表示*/
  -webkit-box-orient: vertical;
}
.peopleNum{
  font-size: 2px;
  font-weight: 400;
  line-height: 20px;
  margin-left: 10px;
  color: #999999;
  display: inline-block;
}
.allocation_box{
  box-sizing: border-box;
  display: flex;
  justify-content: space-between;
   .allocation_left{
    width: 25%;
    margin-right: 15px;
    .allocation_left_title{
      font-size: 14px;
      font-weight: bold;
      color: #333333;
      margin-bottom: 15px;
    }
  }
  .allocation_right{
    width: 75%;
    .result_title{
      font-size: 14 px;
      font-family: PingFang SC;
      font-weight: bold;
      color: #333333;
    }
    .result{
      height: 80px;
      padding: 12px;
      box-sizing: border-box;
      background: #F4F7FC;
      display:flex;
      flex-wrap: wrap;
      overflow-y: scroll;

      // overflow: scroll;
      .result_item{
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: 400;
        color: #666666;
        margin-right: 50px;
        line-height: 28px;
      }
    }
   /deeo/.el-table__header-wrapper {
  background-color:#E3EDFF !important;
}
    .allocation_right_titleBox{
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 5px;

      .allocation_right_title_right{
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: 400;
        line-height: 0px;
        color: #4168E7;
      }
    }
    .allocation_right_title{
      font-size: 14px;
      font-weight: bold;
      color: #333333;
      margin-bottom: 10px;

    }
    .allocation_right_title_btn{

      width: 68px;
      height: 32px;
      background: #E3EDFF;
      opacity: 1;
      border-radius: 4px;
      line-height: 9px;
      color: #4168E7;
      border: none;
      margin-left:15px

    }
  }

}
 .allocationForm{
  border-bottom: 1px dashed #E8EAEC;
  margin-bottom: 20px;
    /deep/.el-form-item{
      margin-bottom: 15px;
    }
  }

.allocation_pagination{
  text-align: right;
}
.resultDialogStyle{
  display: flex;
}
</style>
